package com.qf.day12.homework2;

import com.qf.day12.list.ArtShow;
import org.omg.CORBA.INTERNAL;

import java.util.List;
import java.util.Scanner;

public class TextEditorDemo {
    public static void main(String[] args) {

        TextEditorService textEditorService =new TextEditorImpl();

        while (true){
            System.out.println("1.插入文本\t 2.查询所有\t 3.删除文本\t 4.修改文本\t 5.在指定行插入文本\t 6.退出");
            Scanner scanner=new Scanner(System.in);
            String s = scanner.nextLine();
            switch (s){
                case "1":
                    String s1 = scanner.nextLine();
                    textEditorService.addLine(s1);
                    break;
                case "2":
                    List<String> aLl = textEditorService.getALl();
                    aLl.forEach(e-> System.out.println(e));
                    break;
                case "3":
                    System.out.println("请输入你想删除的行数");
                    int i = scanner.nextInt();
                    textEditorService.deleteLine(i);
                    break;
                case "4":
                    System.out.println("请输入你想修改的行数");
                    int updateLine = Integer.valueOf(scanner.nextLine());
                    System.out.println("请你输入修改后的文本");
                    String s2=scanner.nextLine();
                    textEditorService.updateLine(updateLine,s2);
                    break;
                case "5":
                    System.out.println("请输入你想插入的行数");
                    int insertLine = Integer.valueOf(scanner.nextLine());
                    System.out.println("请你输入插入后的文本");
                    String s3=scanner.nextLine();
                    textEditorService.insertLine(insertLine,s3);
                    break;
                case "6":
                    System.out.println(886);
                    return;
                default:
                    System.out.println("输入有误,请重新输入");
                    break;
            }
        }

    }
}
